import { fallbackPreOrderShipmentStatusApi } from "@/api/waybillManagement/customerServiceWaybill/index";
import { message } from "ant-design-vue";

export default function OperationHook(state: any) {
  const { visible, passData, formState, formRef, emit } = state;
  const onFish = () => {
    console.log("onFish");
    console.log(visible.value);
  };

  const onSubmit = () => {
    formRef.value.validate().then(() => {
      const params = {
        ...formState,
        idList: passData.value.map((t: any) => t.id)
      };

      fallbackPreOrderShipmentStatusApi(params).then((res: any) => {
        const { code, data } = res;
        if (code === 200) {
          message.success(data);
          emit("submit");
        }
      });
    });
  };
  const resetForm = () => {
    formRef.value.resetFields();
    emit("update:visible", false);
  };
  return {
    onFish,
    resetForm,
    onSubmit
  };
}
